import request from '@/axios'
import type { AppQueryCriteria, AppTableView, AppForm } from './types'

export const query = (data: PaginationRequest<AppQueryCriteria>): Promise<PaginationResponse<AppTableView>> => {
    return request.post({
        url: '/app/query',
        data
    })
}

export const get = (id: string): Promise<AppForm> => {
    return request.get({
        url: `/app/${id}`
    })
}


export const add = (data: AppForm): Promise<ApiResult> => {
    return request.post({
        url: '/app',
        data
    })
}

export const edit = (id: string, data: AppForm): Promise<ApiResult> => {
    return request.put({
        url: `/app/${id}`,
        data
    })
}

export const remove = (id: string): Promise<ApiResult> => {
    return request.delete({
        url: `/app/${id}`
    })
}

export const platformOptions = (): Promise<SelectOption[]> => {
    return request.get({
        url: '/app/platform/options'
    })
}
